﻿@{
    ViewData["Title"] = "商户入网界面";
}

<div class="container">
    <div class="row">
        <div class="col-lg-12" style="margin-bottom:0.5rem;">
            <div class="card">
                <div class="card-header">
                    商户名称判重
                </div>
                <div class="card-body">
                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <input type="text" class="form-control" autocomplete="off" placeholder="请输入商户名称">
                        <button type="button" id="WxMchntNameCheck" class="btn btn-primary input-group-append">确认</button>
                    </div>

                    <div class="card text-white bg-dark">
                        <div class="card-body">
                            <h6 class="card-title">返回结果</h6>
                            <div class="card-text" id="wxMchntNameCheckResult"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12" style="margin-bottom:0.5rem;">
            <div class="card">
                <div class="card-header">
                    商户渠道子商户号查询
                </div>
                <div class="card-body">
                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <select id="mchntTp" class="custom-select">
                            <option value="">请选择商户类型</option>
                            <option value="1">微信</option>
                            <option value="2">支付宝</option>
                            <option value="3">微信绿洲</option>
                            <option value="4">支付宝蓝海</option>
                            <option value="5">翼支付</option>
                            <option value="6">银联二维码</option>
                        </select>
                    </div>

                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <div class="input-group-prepend">
                            <span class="input-group-text">申请商户号</span>
                        </div>
                        <input type="text" class="form-control" id="mchntCd">
                    </div>

                    <button type="button" id="ChnlSubMchIdQuery" class="btn btn-primary input-group-append">确认</button>

                    <div class="card text-white bg-dark" style="margin-top:0.5rem;">
                        <div class="card-body">
                            <h6 class="card-title">返回结果</h6>
                            <div class="card-text" id="chnlSubMchIdQueryResult"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12" style="margin-bottom:0.5rem;">
            <div class="card">
                <div class="card-header">
                    商户信息更新
                </div>
                <div class="card-body">
                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <div class="input-group-prepend">
                            <span class="input-group-text">富友商户代码</span>
                        </div>
                        <input type="text" class="form-control" id="fyMchntCd">
                    </div>

                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <div class="input-group-prepend">
                            <span class="input-group-text">商户名称</span>
                        </div>
                        <input type="text" class="form-control" id="mchntName">
                    </div>

                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <div class="input-group-prepend">
                            <span class="input-group-text">商户简称</span>
                        </div>
                        <input type="text" class="form-control" id="mchntShortname">
                    </div>

                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <div class="input-group-prepend">
                            <span class="input-group-text">商户真实名称</span>
                        </div>
                        <input type="text" class="form-control" id="realName">
                    </div>

                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <select id="licenseType" class="custom-select">
                            <option value="">请选择证件类型</option>
                            <option value="0">营业执照</option>
                            <option value="1">三证合一</option>
                            <option value="A">身份证(一证下机)</option>
                            <option value="B">个体户</option>
                            <option value="2">事业单位</option>
                        </select>
                    </div>

                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <div class="input-group-prepend">
                            <span class="input-group-text">证件号码</span>
                        </div>
                        <input type="text" class="form-control" id="licenseNo">
                    </div>

                    <div class="input-group" style="margin-bottom:0.5rem;">
                        <div class="input-group-prepend">
                            <span class="input-group-text">证件到期日</span>
                        </div>
                        <input type="text" class="form-control" id="licenseExpireDt" placeholder="格式yyyyMMdd，长期请填20991231，无有效期请填19000101">
                    </div>

                    <button type="button" id="WxMchntEdit" class="btn btn-primary input-group-append">确认</button>

                    <div class="card text-white bg-dark" style="margin-top:0.5rem;">
                        <div class="card-body">
                            <h6 class="card-title">返回结果</h6>
                            <div class="card-text" id="wxMchntEditResult"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script>
        (function ($) {
            var active = {
                pay: function (action, data, callback) {
                    $.ajax({
                        url: 'merchantaccess/' + action,
                        method: 'post',
                        data: data
                    }).done(function (res) {
                        $('#' + action + 'Result').html('<pre class="text-white"><code>' + JSON.stringify(res) + '</code></pre>');

                        if (res.response.resultCode === '000000') {
                            callback && typeof (callback) === 'function' && callback(res);
                        }
                    }).fail(function (e, status, error) {
                        $('#' + action + 'Result').html('<pre class="text-white"><code>' + e.responseText + '</code></pre>');

                    });
                }
            };

            $('#WxMchntEdit').on('click', function () {
                var licenseExpireDt = $('#licenseExpireDt').val(),
                    licenseNo = $('#licenseNo').val(),
                    licenseType = $('#licenseType').val(),
                    mchntName = $('#mchntName').val(),
                    realName = $('#realName').val(),
                    fyMchntCd = $('#fyMchntCd').val(),
                    mchntShortname = $('#mchntShortname').val();

                active.pay('wxMchntEdit', { 'fyMchntCd': fyMchntCd, 'mchntName': mchntName, 'mchntShortname': mchntShortname, 'realName': realName, 'licenseType': licenseType, 'licenseNo': licenseNo, 'licenseExpireDt': licenseExpireDt });
            });

            $('#WxMchntNameCheck').on('click', function () {
                var mchntName = $(this).siblings('input').val();

                active.pay('wxMchntNameCheck', { 'mchntName': mchntName });
            });

            $('#ChnlSubMchIdQuery').on('click', function () {
                var mchntTp = $('#mchntTp').val(),
                    mchntCd = $('#mchntCd').val();

                active.pay('chnlSubMchIdQuery', { 'mchntTp': mchntTp, 'mchntCd': mchntCd });
            });
        })(jQuery);
    </script>
}
